package ut.Title_1_10;

import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import solution.Title_1_10.TwoSum;

/**
 * @author FreyaZ
 * @version 2018-01-01
 */
public class TwoSumUT {

    @Test
    public void test() {
        List<TwoSumTuple> twoSumList = new ArrayList<>();
        twoSumList.add(new TwoSumTuple(6, new int[] {3, 3}, new int[] {0, 1}));
        twoSumList.add(new TwoSumTuple(9, new int[] {2, 7, 11, 13}, new int[] {0, 1}));

        for (TwoSumTuple tuple : twoSumList) {
            Assert.assertArrayEquals(tuple.getResult(), TwoSum.twoSum(tuple.getNums(), tuple.getTarget()));
        }

        // Assert.assertArrayEquals(new int[] {0, 1}, TwoSum.twoSum(new int[] {3, 3}, 6));
    }


    class TwoSumTuple {
        private int target;
        private int[] nums;
        private int[] result;

        TwoSumTuple(int target, int[] nums, int[] result) {
            this.target = target;
            this.nums = nums;
            this.result = result;
        }

        public int getTarget() {
            return target;
        }

        public int[] getNums() {
            return nums;
        }

        public int[] getResult() {
            return result;
        }
    }

}
